<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ include file="../common.inc" %>  
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style1.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="./js/FusionCharts.js"></script>
<script language="JavaScript" src="./js/sale-monitor.js"></script>
<script type="text/javascript" src="./js/form.js"></script>
<script type="text/javascript" language="javascript">
<!--
	//start 定义一个javascript对象，用于存储行业相关数据
	function industry(industryId,industryName,customerNum){
		this.industryId = industryId;//行业id
		this.industryName = industryName;//行业名称
		this.customerNum = customerNum;//行业对应客户数
	}
	var industrys = new Array();
	<c:forEach items="${reports['Industry']}" var="item" varStatus="s" >
	<c:if test="${empty item.industryId }">
	industrys.push(new industry(${s.count},"未录入",${item.industryCount}));
	</c:if>
	<c:if test="${item.industryId == 0}">
	industrys.push(new industry(${s.count},"未知",${item.industryCount}));
	</c:if>
	<c:if test="${item.industryId > 0}">
	industrys.push(new industry(${s.count},"${item.industryName}",${item.industryCount}));
	</c:if>
	</c:forEach>
	var industrys1 = new Array();
	<c:forEach items="${reports['Area']}" var="item" varStatus="s" >
	<c:if test="${empty item.areaId }">
	industrys1.push(new industry(${s.count},"未录入",${item.areaCount}));
	</c:if>
	<c:if test="${item.areaId == 0}">
	industrys1.push(new industry(${s.count},"未知",${item.areaCount}));
	</c:if>
	<c:if test="${item.areaId > 0}">
	industrys1.push(new industry(${s.count},"${item.areaName}",${item.areaCount}));
	</c:if>
	</c:forEach>
	var industrys2 = new Array();
	<c:forEach items="${reports['CompanyType']}" var="item" varStatus="s" >
	<c:if test="${empty item.companyTypeId }">
	industrys2.push(new industry(${s.count},"未录入",${item.companyType}));
	</c:if>
	<c:if test="${item.companyTypeId == 0}">
	industrys2.push(new industry(${s.count},"未知",${item.companyType}));
	</c:if>
	<c:if test="${item.companyTypeId > 0}">
	industrys2.push(new industry(${s.count},"${item.companyTypeName}",${item.companyType}));
	</c:if>
	</c:forEach>
	var industrys3 = new Array();
	industrys3.push(new industry(1,"新客户",${reports['newCustomerCount']}));
	industrys3.push(new industry(2,"老客户",${reports['oldCustomerCount']}));
	//end 
	
	function pageCustomer(flag){
		document.newsNoticeForm.action = "./manageReport.do?action=allCustomerDevoteAnalysis&flag="+flag;
		document.newsNoticeForm.target = "main";
		document.newsNoticeForm.submit();
	}
	
	function back(){
		window.location.href = "./manageReport.do";
		window.location.target = "main";
	}
	function createReport(){
		
		document.newsNoticeForm.action = "./manageReport.do?action=allCustomerDevoteAnalysis";
		document.newsNoticeForm.target = "main";
		document.newsNoticeForm.submit();
		
	}
	function changeImg(id){
		if(id == 1){
			document.getElementById("img1").className = "btn_back";
			document.getElementById("img2").className = "btn_submit";
			document.getElementById("img3").className = "btn_submit";
			document.getElementById("img4").className = "btn_submit";
			
			document.getElementById("div1").style.display = "block";
			document.getElementById("div2").style.display = "none";
			document.getElementById("div3").style.display = "none";
			document.getElementById("div4").style.display = "none";
		}else if(id == 2){
			document.getElementById("img2").className = "btn_back";
			document.getElementById("img1").className = "btn_submit";
			document.getElementById("img3").className = "btn_submit";
			document.getElementById("img4").className = "btn_submit";
			document.getElementById("div2").style.display = "block";
			document.getElementById("div1").style.display = "none";
			document.getElementById("div3").style.display = "none";
			document.getElementById("div4").style.display = "none";
		}else if(id == 3){
			document.getElementById("img3").className = "btn_back";
			document.getElementById("img1").className = "btn_submit";
			document.getElementById("img2").className = "btn_submit";
			document.getElementById("img4").className = "btn_submit";
			
			document.getElementById("div3").style.display = "block";
			document.getElementById("div1").style.display = "none";
			document.getElementById("div2").style.display = "none";
			document.getElementById("div4").style.display = "none";
		}else if(id == 4){
			document.getElementById("img4").className = "btn_back";
			document.getElementById("img3").className = "btn_submit";
			document.getElementById("img1").className = "btn_submit";
			document.getElementById("img2").className = "btn_submit";
			document.getElementById("div4").style.display = "block";
			document.getElementById("div1").style.display = "none";
			document.getElementById("div2").style.display = "none";
			document.getElementById("div3").style.display = "none";
		}
	}
	function aaa(aaa){
		window.location.href = aaa;
		window.location.target = "main";
		}
-->
</script>
</head>
<body>
<form name="newsNoticeForm" action="" method="post">
<table class="table_frame">
		<tr>
			<td>
				<table class="table_title2">
					<tr>
						<td>
						
							<table cellpadding="0" cellspacing="0" width="100%" height="100%">
								<tr>
									<td class="title_lab">分析报表</td>
									<td align="left">&nbsp;&nbsp;快速查看：
									<select onchange="aaa(this.options[this.selectedIndex].value);">
									<option>-------------请选择-------------</option>
									<option value="./manageReport.do?action=preSalePeriodReport">销售周期分析表</option>
									<option value="./manageReport.do?action=saleMonthReport">销售月度统计表</option>
									<option value="./manageReport.do?action=allCustomerDevoteAnalysis">客户贡献统计表</option>
									<option value="./manageReport.do?action=oldCustomerDevoteAnalysis">老客户贡献分析表</option>
									<option value="./manageReport.do?action=marketExpandsAnalysis">市场开拓同步分析表</option>
									<option value="./manageReport.do?action=annualWreathCompares">年度环比分析表</option>
									<option value="./manageReport.do?action=getLinkManMailInfo">联系人邮件列表</option>
									<option value="./manageReport.do?action=CustomerStatisticContract">按客户统计合同</option>
									<option value="./manageReport.do?action=saleStatisticContract">按销售统计合同</option>
									
									</select>
								</tr>
							</table>
						</td>
					</tr>
									<!--<tr>
						<td>
							<table>
										
										<tr>
											<td class="title"> 行业 
												<c:choose>
													<c:when test="${language == 2}">${records['110'].currentRecordEn}：</c:when>
													<c:otherwise>${records['110'].currentRecord}：</c:otherwise>
												</c:choose>
											</td>
											<td width="">
												<select id="industryId" name="industryId" onchange="industryChangeEdit(this)">
													<option value="" <c:if test='${customer.industryId == 0}'>selected</c:if> >----默认全部----</option>
													<c:forEach var="range" items="${ranges['110']}">
													<option value="${range.id}" <c:if test='${customer.industryId == range.id}'>selected</c:if> >${range.rangeValue}</option>
													</c:forEach>
												</select>
											</td>
											<td class="title"> 企业类型 
												<c:choose>
													<c:when test="${language == 2}">${records['113'].currentRecordEn}：</c:when>
													<c:otherwise>${records['113'].currentRecord}：</c:otherwise>
												</c:choose>
											</td>
											<td width="">
												<select id="companyTypeId" name="companyTypeId">
													<option value="" <c:if test='${customer.companyTypeId == 0}'>selected</c:if> >----默认全部----</option>
													<c:forEach var="range" items="${ranges['113']}">
													<option value="${range.id}" <c:if test='${customer.companyTypeId == range.id}'>selected</c:if> >${range.rangeValue}</option>
													</c:forEach>
												</select>
											</td>
										</tr>
										
										<tr>
										
											<td class="title"> 区域 
												<c:choose>
													<c:when test="${language == 2}">${records['111'].currentRecordEn}：</c:when>
													<c:otherwise>${records['111'].currentRecord}：</c:otherwise>
												</c:choose>
											</td>
											<td width="">
												<select id="areaId" name="areaId">
													<option value="" <c:if test='${customer.areaId == 0}'>selected</c:if> >----默认全部----</option>
													<c:forEach var="range" items="${ranges['111']}">
													<option value="${range.id}" <c:if test='${customer.areaId == range.id}'>selected</c:if> >${range.rangeValue}</option>
													</c:forEach>
												</select>
											</td>
											 
											<td class="title">销售状态</td>
											<td>
												<select id="areaId11" name="areaId11">
												<option value="" >----默认全部----</option>
												<option value="6" <c:if test='${customer.saleStatusForSelect == 6}'>selected</c:if>>休眠</option>
												<option value="1" <c:if test='${customer.saleStatusForSelect == 1}'>selected</c:if>>潜在客户</option>
												<option value="2" <c:if test='${customer.saleStatusForSelect == 2}'>selected</c:if>>意向客户</option>
												<option value="3" <c:if test='${customer.saleStatusForSelect == 3}'>selected</c:if>>立项客户</option>
												<option value="4" <c:if test='${customer.saleStatusForSelect == 4}'>selected</c:if>>价值客户</option>
												<option value="5" <c:if test='${customer.saleStatusForSelect == 5}'>selected</c:if>>商务谈判</option>
											</td>
										</tr>
										
							</table>
						</td>
					</tr>
					
					--><tr><td colspan="3" height="50" style="height: 55px;text-align: center;font-weight: bold;font-size: 24px;">客户贡献分析表</td></tr>
						<tr>
						<td>
							<table align="center" class="table_report1">
										
										<tr>
											<td class="title" align="right"><!-- 行业 -->
												<c:choose>
													<c:when test="${language == 2}">${records['110'].currentRecordEn}：</c:when>
													<c:otherwise>${records['110'].currentRecord}：</c:otherwise>
												</c:choose>
												
											</td>
											
											<td width="">
												<select id="industryId" name="industryId" onchange="industryChangeEdit(this)">
													<option value="" <c:if test='${customer.industryId == 0}'>selected</c:if> >----默认全部----</option>
													<c:forEach var="range" items="${ranges['110']}">
													<option value="${range.id}" <c:if test='${customer.industryId == range.id}'>selected</c:if> >${range.rangeValue}</option>
													</c:forEach>
												</select>
												
											</td>
											<td class="title" align="right"><!-- 企业类型 -->
												<c:choose>
													<c:when test="${language == 2}">${records['113'].currentRecordEn}：</c:when>
													<c:otherwise>${records['113'].currentRecord}：</c:otherwise>
												</c:choose>
												
											</td>
											<td width="">
												<select id="companyTypeId" name="companyTypeId">
													<option value="" <c:if test='${customer.companyTypeId == 0}'>selected</c:if> >----默认全部----</option>
													<c:forEach var="range" items="${ranges['113']}">
													<option value="${range.id}" <c:if test='${customer.companyTypeId == range.id}'>selected</c:if> >${range.rangeValue}</option>
													</c:forEach>
												</select>
												
											</td>
										</tr>
										
										<tr>
											<td class="title" align="right"><!-- 区域 -->
												<c:choose>
													<c:when test="${language == 2}">${records['111'].currentRecordEn}：</c:when>
													<c:otherwise>${records['111'].currentRecord}：</c:otherwise>
												</c:choose>
												
											</td>
											<td width="">
												<select id="areaId" name="areaId">
													<option value="" <c:if test='${customer.areaId == 0}'>selected</c:if> >----默认全部----</option>
													<c:forEach var="range" items="${ranges['111']}">
													<option value="${range.id}" <c:if test='${customer.areaId == range.id}'>selected</c:if> >${range.rangeValue}</option>
													</c:forEach>
												</select>
											
											</td>
											<td class="title" align="right">销售状态：</td>
											<td>
												<select id="saleStageId" name="saleStageId">
												<option value="" selected>----默认全部----</option>
												<c:forEach var="range" items="${saleStages }">
												<option value="${range.stageCode}" <c:if test='${customer.saleStageId == range.stageCode}'>selected</c:if> >${range.stageName}</option>
												</c:forEach>
												<option value="0" <c:if test='${customer.saleStageId == 0}'>selected</c:if> >休眠</option>
											</td>
										</tr>
										
							</table>
						</td>
					</tr>
					
					<tr>
						<td align="center">
							<table class="table_report1" cellpadding="0" cellspacing="0" height="100%" style="width: 95%;">
								<tr>
									<td align="center" height="30">
										<input class="btn_report" type="button" value="" onclick="createReport()"/>&nbsp;&nbsp;
										<button class="btn_back" onclick="back()" hidefocus="true">返回</button>
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td align="center">
								<table class="table_sreport" style="width: 95%;">
									<tr>
										<td class="title">客户名称</td>
										<td class="title">老客户</td>
										<td class="title">行业</td>
										<td class="title">区域</td>
										<td class="title">企业类型</td>
										<td class="title">签约金额</td>
										<td class="title">合同数量</td>
										<td class="title">平均单产</td>
										<td class="title">销售状态</td>
									</tr>
									<c:forEach items="${reports['report']}" var="item">
									<tr onmouseover="onmousemoveChange(this,'img${item.id}')" onmouseout="onmouseoutChange(this,'img${item.id}')">
										<td>${item.customerName }</td>
										<td>
										<c:choose>
											<c:when test="${item.contractCount >= 2}">是</c:when>
											<c:otherwise>否</c:otherwise>
										</c:choose>
										</td>
										<td>${item.industryName }</td>
										<td>${item.areaName }</td>
										<td>${item.companyTypeName }</td>
										<td>￥<c:choose>
												<c:when test="${!empty item.totalcontractCost}">
													<fmt:formatNumber value="${item.totalcontractCost }" pattern="###,###,###,###.##"/>
												</c:when>
												<c:otherwise>
													0
												</c:otherwise>
											</c:choose>
											</td>
										<td>
										<c:choose>
												<c:when test="${!empty item.contractCount}">
													${item.contractCount }
												</c:when>
												<c:otherwise>
													0
												</c:otherwise>
											</c:choose>
										</td>
										<td>
										￥<c:choose>
												<c:when test="${!empty item.avgContractCost}">
													<fmt:formatNumber value="${item.avgContractCost }" pattern="###,###,###,###.##"/>
												</c:when>
												<c:otherwise>
													0
												</c:otherwise>
											</c:choose>
										
										</td>
										<td>
											<c:choose>
												<c:when test="${item.saleStatus != 0 && item.saleStatus !=null}">
													休眠
												</c:when>
												<c:otherwise>
													${item.stageName }
												</c:otherwise>
											</c:choose>
										</td>
									</tr>
									</c:forEach>
								</table>
						</td>
					</tr>
					<tr>
						<td align="center">
							<table class="table_page" style="width: 95%;text-align: left;">
								<tr>
									<td>&nbsp;&nbsp;
										<img src="./images/frist.bmp" onclick="pageCustomer(1)" alt="首页" style="vertical-align: middle;cursor: hand;">
										<img src="./images/last.bmp" onclick="pageCustomer(2)" alt="上一页" style="vertical-align: middle;cursor: hand;">&nbsp;
										<font color="red">${currentPage}</font>/${totalPages}&nbsp;<fmt:message key='common.page'/>&nbsp;
										<img src="./images/next.bmp" onclick="pageCustomer(3)" alt="下一页" style="vertical-align: middle;cursor: hand;">
										<img src="./images/end.bmp" onclick="pageCustomer(4)" alt="末页" style="vertical-align: middle;cursor: hand;">
										共&nbsp;&nbsp;${totalRows}&nbsp;<fmt:message key='common.page.totalRow'/>
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr><td><br></td></tr>
					<tr>
						<td class="title_info" style="text-align: center;">图形分析</td>
					</tr>
					<tr>
						<td align="center">
							<table class="table_report1" cellpadding="0" cellspacing="0" height="100%" style="width: 95%;text-align: left;">
								<tr>
									<td align="" height="30">
										<button id="img1" class="btn_back" onclick="changeImg(1)" hidefocus="true">按行业</button>
										<button id="img2" class="btn_submit" onclick="changeImg(2)" hidefocus="true">按区域</button>
										<button id="img3" class="btn_submit" onclick="changeImg(3)" hidefocus="true">按企业类型</button>
										<button id="img4" class="btn_submit" onclick="changeImg(4)" hidefocus="true">按新老客户</button>
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td height="200" align="center" >
							<table class="table" style="width: 95%;text-align: center;">
								<tr>
									<td align="center">
										<div id="div1" style="display: block;">
											<div id="chartdiv11" align="center">老客户贡献分析图按行业</div>
											<script type="text/javascript">
												oldCustomerDevoteAnalysisByIndustry("chartdiv11",industrys);
											</script> 
										</div>
										<div id="div2" style="display: none;">
											<div id="chartdiv22" align="center">老客户贡献分析图按区域</div>
											<script type="text/javascript">
												oldCustomerDevoteAnalysisByIndustry("chartdiv22",industrys1);
											</script>
										</div>
										<div id="div3" style="display: none;">
											<div id="chartdiv33" align="center">老客户贡献分析图按企业类型</div>
											<script type="text/javascript">
												oldCustomerDevoteAnalysisByIndustry("chartdiv33",industrys2);
											</script>
										</div>
										<div id="div4" style="display: none;">
											<div id="chartdiv44" align="center">老客户贡献分析图按新老客户</div>
											<script type="text/javascript">
												oldCustomerDevoteAnalysisByIndustry("chartdiv44",industrys3);
											</script>
										</div>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
	</form>								
</body>
</html>